a = int(input())
b = dict()
e = []
for i in range(a):
    c = input()
    c = c.split(" ")
    key = int(c[0])
    value = int(c[1])
    if key not in e:
        b[key] = value
        e.append(key)
    else:
        b[key] = b.get(key) + value

for key in sorted(b,):
    print(key, end=" ")
    print(b.get(key))


